package thinkingJava.chapter17;

import java.util.Iterator;

import thinkingJava.chapter15.Generator;
import thinkingJava.chapter16.CountingGenerator;
import thinkingJava.chapter16.RandomGenerator;

class Letter implements Generator<Pair<Integer,String>>, Iterable<Integer> {
	private int size = 9 ;
	private int number = 1;
	private char letter = 'A';
	public Pair<Integer, String> next() {
		return new Pair<Integer,String>(number++, "" + letter++);
	}
	public Iterator<Integer> iterator() {
		return new Iterator<Integer>() {
			public boolean hasNext() {
				return number < size;
			}
			public Integer next() {
				return number++;
			}
			public void remove() {
				throw new UnsupportedOperationException();
			}
		};
	}
}
public class MapDataTest {
	public static void main(String[] args) {
		print(MapData.map(new Letter(), 11));
		print(MapData.map(new CountingGenerator.Character(), new RandomGenerator.String(3) , 8));
		print(MapData.map(new CountingGenerator.Character(), "Value", 6));
		print(MapData.map(new Letter(), new RandomGenerator.String(3)));
		print(MapData.map(new Letter(), "Pop"));
	}
	public static void print(Object o) {
		System.out.println(o);
	}
}
